package com.lvmama.controller.dw;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.lvmama.common.result.Result;
import com.lvmama.pojo.dto.dw.RepruchaseAnalysisQuery;
import com.lvmama.pojo.entity.dw.RepruchaseAnalysis;
import com.lvmama.service.dw.RepurchaseService;

/**
 * @Author:xuzhongwei
 * @Description:
 * @Date：2018/08/06
 */
@RestController
@RequestMapping("/repurchase")
public class RepurchaseController {

	@Autowired
	RepurchaseService repurchaseService;
    /**
     * 查询复购分析结果
     * @param query 查询条件
     * @return 结果集
     */
	@PostMapping("/queryRepruchaseAnalysisList")
	Result<List<RepruchaseAnalysis>> queryRepruchaseAnalysisList(@RequestBody RepruchaseAnalysisQuery query){
		return repurchaseService.queryRepruchaseAnalysisList(query);
	}

    /**
     * 查询最近一条记录
     * @return 最近一条记录
     */
	@GetMapping("/selectLatestRecord")
	Result<RepruchaseAnalysis> selectLatestRecord(){
		return repurchaseService.selectLatestRecord();
		
	}

    /**
     * 获取复购率推送时间列表
     * @return 结果集
     */
	@GetMapping("/getCreateTimeList")
	Result<List<RepruchaseAnalysis>> getCreateTimeList(){
		return repurchaseService.getCreateTimeList();
	}
	
	/**
     * 获取复购分布结果
     * @return 结果集
     */
	@PostMapping("/getDistributionResult")
	Result<Map<String, Object>> getDistributionResult(String chooseTime){
		return repurchaseService.getDistributionResult(chooseTime);
	}
	
	/**
     * 获取复购属性定位结果
     * @return 结果集
     */
	@GetMapping("/getAttributesResult")
	Result<Map<String, Object>> getAttributesResult(String chooseTime){
		return repurchaseService.getAttributesResult(chooseTime);
	}
}
